/*
 * @Author: your name
 * @Date: 2021-09-08 12:43:35
 * @LastEditTime: 2025-03-11 12:54:07
 * @LastEditors: 1245040330 32012815+1245040330@users.noreply.github.com
 * @Description: In User Settings Edit
 * @FilePath: \vue-cl\vue.config.js
 */

const path = require('path')
const name = 'cl' // page title
const port = 9528 // dev port
function resolve(dir) {
    return path.join(__dirname, dir)
}
module.exports = {
    publicPath: './',
    productionSourceMap: false,
    filenameHashing: true,
    assetsDir: 'static',
    configureWebpack: {
        optimization: {
            nodeEnv: false
        },
        externals: {
            'vue': 'Vue',
            'element-ui': 'ELEMENT',
        },
        name: name,
        resolve: {
            fallback: {
                path: require.resolve('path-browserify'),
            },
            alias: {
                '@': resolve('src')
            }
        }
    },
    parallel: true,
    lintOnSave: false,
    devServer: {
        allowedHosts: 'all',
        port: port,
        client: {
            overlay: false,
        },
        open: true,
        historyApiFallback: true,
        proxy: {
            ['']: {
                target: 'http://localhost:8080/DigitalCampus_V5.0/',
                changeOrigin: true,
            },
        },
    },
    chainWebpack: config => {
      
        config.module
            .rule('vue')
            .use('thread-loader')
            .loader('thread-loader')
            .end();
        config.module
            .rule('js')
            .use('thread-loader')
            .loader('thread-loader')
            .end();
        config.optimization.minimizer('terser').tap((args) => {
            args[0].terserOptions = {
                mangle: false,
                compress: {
                    warnings: true,
                    drop_console: true,
                    drop_debugger: true
                }
            }
            return args
        })
        config.plugin('html').tap(args => {
            args[0].minify = false
            args[0].xhtml = true
            return args
        })

        config.plugins.delete('fork-ts-checker') // 禁用fork-ts-checker
        config.plugins.delete("prefetch");
        config.module
            .rule('image')
            .test(/\.(JPG|JPEG|PNG|GIF|BMP|TTF|SVG|ico|png)$/)
            .use('url-loader')
            .loader('url-loader');
        config.module
            .rule('vue')
            .use('vue-loader')
            .loader('vue-loader')
            .tap(options => {
                options.compilerOptions.whitespace = 'preserve'
                return options
            });
        console.log("process.env.NODE_ENV", process.env.NODE_ENV);
    },
 
}